<template>
	<view>
		 <web-view :webview-styles="webviewStyles" :src="url" @message="getMessage"></web-view>
	</view>
</template>

<script setup lang="ts">
  

  import { ref } from 'vue';
  import { onShow,onLoad,onUnload} from '@dcloudio/uni-app';
  const url = ref('')
  const dataInfo = ref('')
  const webviewStyles = ref({
    progress: {
    	color: '#FF3333'
    }
  })
  onLoad((options)=>{
    // 获取传递过来的链接
    url.value = JSON.parse(decodeURIComponent(options.urlPath));
    const paramData = JSON.parse(decodeURIComponent(options.paramData));
    if(options.dataInfo){
      dataInfo.value = decodeURIComponent(options.dataInfo)
      uni.setStorageSync('storedGoodsId', JSON.parse(dataInfo.value).cardId);
      console.log(dataInfo,'--------------------------------------------')
    }
    if (url.value.substring(0, 3) == 'www') {
    	url.value = 'https://' + url.value
    }
    
    if(paramData){
    	const sysnum = paramData.sysnum || '';
      const useWxjs = 'useWxjs=true';
      const cardInfoParam = dataInfo.value ? `&card_info=${dataInfo.value}` : '';
  
      url.value = `${url.value}?sysnum=${sysnum}${cardInfoParam}&${useWxjs}`;
    	
      console.log(url.value,'--------------------------------------------')
    }
  })
  
  const getMessage = (e)=> {
  	console.log('message', e)
  }
  
</script>

<style>

</style>
